package com.leetcode.LC;

public class LC657 {
    public boolean judgeCircle(String moves) {

        if (moves.length()%2!=0){
            return false;
        }else if (moves.length()==0){
            return true;
        }

        int[] ints = new int[2];
        for (int i = 0; i < moves.length(); i++) {
            if (moves.charAt(i)=='R'){
                ints[0]++;
            }else if(moves.charAt(i)=='L'){
                ints[0]--;
            }else if(moves.charAt(i)=='U'){
                ints[1]++;
            }else if(moves.charAt(i)=='D'){
                ints[1]--;
            }
        }

        for (int anInt : ints) {
            if (anInt!=0){
                return false;
            }
        }
        return true;

    }
}
